using System;
using System.Collections.Generic;
using Microsoft.Xna.Framework;
using Microsoft.Xna.Framework.Content;
using Microsoft.Xna.Framework.Graphics;

namespace Comp_GeoData
{
    public class Map //: DrawableGameComponent
    {
        #region Members

        private Vector2 kittenStartPosition;
        private Vector2 monsterStartPosition;

        private List<LineSegment> lineSegments;

        #endregion

        #region Paramaters

        public Vector2 KittenStartPosition
        {
            get { return kittenStartPosition; }
            set { kittenStartPosition = value; }
        }

        public Vector2 MonsterStartPosition
        {
            get { return monsterStartPosition; }
            set { monsterStartPosition = value; }
        }

        public List<LineSegment> LineSegments
        {
            get { return lineSegments; }
            set { lineSegments = value; }
        }

        #endregion

        #region Draw

        public void DrawMap(GameTime gameTime, SpriteBatch spriteBatch, Texture2D dotTexture)
        {
            if (lineSegments != null)
            {
                foreach (LineSegment line in lineSegments)
                {
                    if (line.StartPoint.X == line.EndPoint.X)
                    {
                        if (line.StartPoint.Y < line.EndPoint.Y)
                        {
                            for (int i = (int)line.StartPoint.Y; i < line.EndPoint.Y; i++)
                            {
                                spriteBatch.Draw(dotTexture, new Vector2(line.StartPoint.X, i), Color.Red);
                            }
                        }
                        else
                        {
                            for (int i = (int)line.StartPoint.Y; i > line.EndPoint.Y; i--)
                            {
                                spriteBatch.Draw(dotTexture, new Vector2(line.StartPoint.X, i), Color.Red);
                            }
                        }
                    }
                    if (line.StartPoint.Y == line.EndPoint.Y)
                    {
                        if (line.StartPoint.X < line.EndPoint.X)
                        {
                            for (int i = (int)line.StartPoint.X; i < line.EndPoint.X; i++)
                            {
                                spriteBatch.Draw(dotTexture, new Vector2(i, line.StartPoint.Y), Color.Red);
                            }
                        }
                        else
                        {
                            for (int i = (int)line.StartPoint.X; i > line.EndPoint.X; i--)
                            {
                                spriteBatch.Draw(dotTexture, new Vector2(i, line.StartPoint.Y), Color.Red);
                            }
                        }
                    }
                }
            }
        }

        #endregion
    }
}
